<template>
  <div class="divBox">
    <el-card class="box-card">
<!--      <div style="width: 500px;display: flex;justify-content: center">-->
<!--        <div style="">-->

<!--          <span>-->
<!--            <template v-if="type==1">-->
<!--              平台用户总抽成益联券量:-->
<!--            </template>-->
<!--            <template v-else>-->
<!--              兑换商品上级分佣积分:-->
<!--            </template>-->
<!--            <i style="font-weight: bold;color: green;font-size: 28px;">{{dataInfo.statisticalPlatform}}</i> </span>-->
<!--        </div>-->
<!--        <div style="margin-left: 20px">-->
<!--          <span>-->
<!--             <template v-if="type==1">-->
<!--              兑换商品平台收回总益联券:-->
<!--            </template>-->
<!--             <template v-else>-->
<!--              兑换商品平台收回积分:-->
<!--            </template>-->
<!--            <i style="font-weight: bold;color:#1e6abc;font-size: 28px;">{{dataInfo.statisticalOther}}</i></span>-->
<!--        </div>-->

<!--      </div>-->

    </el-card>
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="时间范围">
          <el-date-picker
              v-model="value1"
              type="datetimerange"
              value-format="yyyy-MM-dd HH:mm:ss"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              @change="handleDateChange">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="类型：">
          <el-select v-model="listPram.typeName" placeholder="请选择">
            <el-option
                v-for="item in typeList"
                :key="item.id"
                :label="item.name"
                :value="item.name" class="selWidth">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click.native="getList">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-table v-loading="formLoading" :data="listData.records" style="width: 100%" size="small" highlight-current-row>

          <el-table-column prop="id" label="ID" min-width="50"/>
          <el-table-column prop="nickName" label="用户" min-width="80"/>
          <el-table-column prop="mobile" label="手机号" min-width="100"/>
          <el-table-column prop="typeName" label="类型" min-width="150"/>
        <el-table-column prop="pumpingType" label="变动类型" min-width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.pumpingType==1">平台新增</span>
            <span v-if="scope.row.pumpingType==2">平台扣减</span>
          </template>
        </el-table-column>
          <el-table-column  v-if="type==1" prop="value" label="益联券" min-width="150"/>
          <el-table-column  v-if="type==2" prop="value" label="积分" min-width="150"/>
          <el-table-column prop="createTime" label="时间" min-width="150"/>
        <el-table-column label="操作" min-width="80" fixed="right" align="center">
          <template slot-scope="scope">
            <el-button  size="mini" type="primary" @click="jumpNewPage(scope.row.mobile)"  >详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[10,20,50,80,100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listData.total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>
<script>
import {
  platformUserList,
  platformUserValue
} from "@/api/home";


export default {
  components: {},
  props: {
    type: {
      default: null
    }
  },
  data() {
    return {
      value1:'',
      formLoading: false,
      listData: {records: [], total: 0},
      value: [],
      dataInfo:{
        statisticalOther:0,
        statisticalPlatform:0
      },
      typeList: [
        {name: "平台用户抽成益联券"},
        {name: "兑换商品上级分佣积分"},
        {name: "兑换商品平台收回积分"},
        {name: "兑换商品平台收回益联券"}
      ],
      listPram: {
        page: 1,
        limit: 10,
        type:null,
        typeName:'',
        startTime: '',
        endTime: ''
      },
    }
  },
  mounted() {
    if(this.type)
    {
      this.listPram.type=this.type
    }
    this.getList();
    this.getData()
  },
  methods: {
    getData()
    {
      platformUserValue(this.listPram).then(res=>{
        this.dataInfo=res
      })
    },
    jumpNewPage(mobile) {
      if(this.type==1)
      {
        let routeLogin = this.$router.resolve({
          path: "/financial/CommissionRecord",
          query: {
            keyword: `${mobile}`
          }
        });
        window.open(routeLogin.href, '_blank');
      }else if(this.type==2)
      {
        let routeLogin = this.$router.resolve({
          path: "/financial/circulation",
          query: {
            ifVI: 2,
            typeName:'兑换',
            keyword: `${mobile}`
          }
        });
        window.open(routeLogin.href, '_blank');
      }

    },
    handleDateChange(value) {
      this.listPram.startTime = value[0];
      this.listPram.endTime = value[1];
    },
    getList() {

        platformUserList(this.listPram).then(res => {
          this.listData = res
        }).finally(() => {
          this.formLoading = false;
          this.getData();
        })


    },
    close() {
      this.$emit('hideEditDialog')
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
    resetQuery() {
      this.value1=''
      this.listPram.page = 1;
      this.listPram.typeName = '';
      this.listPram.limit = 10;
      this.listPram.endTime = '';
      this.listPram.startTime = '';

      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep {
  .el-upload {
  }
}

.img {
  width: 80px;
  height: 80px;
  border-radius: 100px;
}
</style>
